package com.shu.controller;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.shu.util.ResponseUtil;

@Controller
public class LoginController {
    private static Log logger = LogFactory.getLog(LoginController.class);

	@RequestMapping(value = {"/loginPage","/","/home","/login"})	
	public String loginPage(@RequestParam(value = "error", required = false) String error) {
		Authentication auth = SecurityContextHolder.getContext().getAuthentication();
		String message = "";
		if (error != null) 
		{
			message = "帐号或密码错误！";
		}else {
			if(null!=auth && !(auth instanceof AnonymousAuthenticationToken)) //用户已经登录
			{
				return "home";
			}
		}
		
		return "login";
		
	}
	
}
